﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Konyvkolcsonzo
{
    public class FormKK: Form
    {
        public Panel pnlLeft;
        public Panel pnlRight;
        private bool type;
        public FormKK() : base()
        {
            setLargeSize();
            pnlLeft = new Panel();
            pnlLeft.SetBounds(0,0,520,325);
            pnlLeft.Margin = new Padding(0, 0, 0, 0);
            pnlLeft.Location = new Point(0, 0);
            //pnlLeft.BackColor = Color.Red;
            pnlLeft.SendToBack();
            this.Controls.Add(pnlLeft);
            pnlRight = new Panel();
            pnlRight.SetBounds(525, 0, 253, 325);
            pnlRight.Margin = new Padding(0, 0, 0, 0);
            pnlRight.Location = new Point(525, 0);
            //pnlRight.BackColor = Color.Green;
            pnlRight.SendToBack();
            this.Controls.Add(pnlRight);
            this.visibleEdit(false);
            setSmallSize();
        }

        public void setSmallSize()
        {
            this.Size = new Size(100, 100);
            this.Width = 545;
            this.Height = 370;
            //this.SetBounds(100,100,545,370);
        }

        public void setLargeSize()
        {
            this.Size = new Size(100, 100);
            this.Width = 800;
            this.Height = 370;
        }

        private void setSize(int width, int height)
        {
            this.Width = width;
            this.Height = height;
        }

        public void setTitle(string title)
        {
            this.Text = title + " - Könyvkölcsönző";
        }

        private void visibleEdit(bool visible)
        {
            if (visible)
            {
                this.setLargeSize();
                pnlLeft.Enabled = false;
                pnlRight.Visible = true;
            }
            else
            {
                pnlLeft.Enabled = true;
                pnlRight.Visible = false;
                this.setSmallSize();
            }
        }

        public void cmdAdd()
        {
            this.visibleEdit(true);
            editType(false);
        }

        public bool cmdEdit(int selectedRowsNumber)
        {
            if (selectedRowsNumber == 0)
            {
                MessageBox.Show("Jelöld ki a sort, amelyiket módosítani szeretnéd!", "Hiányzó kijelölés",
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            this.visibleEdit(true);
            editType(true);
            return true;
        }

        public bool cmdDelete(int selectedRowsNumber)
        {
            if (selectedRowsNumber == 0)
            {
                MessageBox.Show("Jelöld ki a sort, amelyiket törölni szeretnéd!", "Hiányzó kijelölés",
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            return (MessageBox.Show("Biztosan szeretnéd törölni a kijelölt sort?", "Törlés megerősítése",
                MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK);
        }

        public void cmdClose()
        {
            this.Close();
        }

        public void cmdExit()
        {
            if (MessageBox.Show("Biztosan ki szeretnél lépni az alkalmazásból?", "Kilépés megerősítése",
                MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
            {
                Application.Exit();
            }
        }

        public void cmdOK()
        {
            this.visibleEdit(false);
        }

        public void cmdCancel()
        {
            this.visibleEdit(false);
        }

        private void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // FormKK
            // 
            this.ClientSize = new System.Drawing.Size(284, 262);
            this.Name = "FormKK";
            this.ResumeLayout(false);
        }

        public bool editType()
        {
            return type;
        }

        public void editType(bool t)
        {
            type = t;
        }
    }
}
